package com.wstx.mediaserver.controller;

import com.alibaba.fastjson.JSON;
import com.wstx.mediaserver.common.Res;
import com.wstx.mediaserver.domain.dto.VideoInfo;
import com.wstx.mediaserver.service.AyakaService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/ayaka")
public class AyakaController {
    final AyakaService service;

    @PostMapping("/postStr")
    public Res<String> postStr(@RequestParam("a") String a){
        try {
            String res = service.postStr(a);
            return new Res<>(Res.sucCode,Res.sucMsg,res);
        }catch (Exception e){
            e.printStackTrace();
            return Res.fail(e.getMessage());
        }
    }

    @PostMapping("/videoRecordMsg")
    public void recordMsgReceive(@RequestBody String msgStr){
        System.out.println(msgStr);
        VideoInfo videoInfo = JSON.parseObject(msgStr, VideoInfo.class);
        System.out.println(videoInfo);
    }

    @GetMapping("/getTest")
    public Res<String> getTest() throws InterruptedException {
        Thread.sleep(3000);
        return new Res<>(Res.sucCode,Res.sucMsg,"哈哈");
    }

    @GetMapping("/cmpTree")
    public Res<String> cmpTree() throws InterruptedException {
        return new Res<>(Res.sucCode,Res.sucMsg,"哈哈");
    }
}
